﻿//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Security;
//using System.Text;
//using RanbuOM.Common;
//using RanbuOM.Serialization;
//using RanbuOM.Utilities;

//namespace RanbuOM.SSF4.EMA
//{
//    [RanbuDataType]
//    public class EmaAnimHeader : RanbuDataItem
//    {
//        [RanbuDataProperty]
//        public UInt16 Duration { get; set; }

//        [RanbuDataProperty]
//        public UInt16 CmdOffsetCount { get; set; }

//        [RanbuDataProperty]
//        public UInt32 ValueCount { get; set; }

//        [RanbuDataProperty]
//        public UInt32 Zero { get; set; }

//        [RanbuDataProperty]
//        public UInt32 NameOffset { get; set; }

//        [RanbuDataProperty]
//        public UInt32 ValueOffset { get; set; }

//        [RanbuDataProperty(SizeParam = "CmdOffsetCount")]
//        public UInt32[] CmdOffsets { get; set; }

//        [RanbuDataProperty(OffsetArrayParam = "CmdOffsets", OffsetMode = OffsetMode.GotoAndStay)]
//        public EmaAnimCommandHeader[] Commands { get; set; }

//        [RanbuDataProperty(SizeParam = "ValueCount", OffsetParam = "ValueOffset", OffsetMode = OffsetMode.GotoAndStay)]
//        public Single[] Values { get; set; }

//        [RanbuDataProperty(OffsetParam = "NameOffset", OffsetMode = OffsetMode.GotoAndTrackBack)]
//        public EmaAnimName Name { get; set; }
//    }

//    [RanbuDataType(Monoblock = true)]
//    public class EmaAnimName : RanbuDataItem
//    {
//        [RanbuDataProperty(SizeConst = 0xA)]
//        public byte[] Zero { get; set; }

//        [RanbuDataProperty]
//        public byte Length { get; set; }

//        public UInt32 AlignedLength
//        {
//            get { return ((uint)(this.Length + 12)).Align(4) - 11; }
//        }

//        [RanbuDataProperty(SizeParam = "AlignedLength")]
//        public string Value { get; set; }
//    }

//    [RanbuDataType(Monoblock = true)]
//    public class EmaAnimCommandHeader : RanbuDataItem
//    {
//        [RanbuDataProperty]
//        public UInt16 BoneIndex { get; set; }

//        [RanbuDataProperty]
//        public Byte TransformType { get; set; }

//        [RanbuDataProperty]
//        public Byte Flags { get; set; }

//        [RanbuDataProperty]
//        public UInt16 StepCount { get; set; }

//        [RanbuDataProperty]
//        public UInt16 StepIndexOffset { get; set; }

//        public UInt32 Timing8Count
//        {
//            get { return (this.Flags & 0x20) == 0 ? this.StepCount.Align(4) : (uint)0; }
//        }

//        public UInt32 Timing16Count
//        {
//            get { return (this.Flags & 0x20) != 0 ? this.StepCount.Align(2) : (uint)0; }
//        }

//        public UInt32 Index16Count
//        {
//            get { return (this.Flags & 0x40) == 0 ? this.StepCount.Align(2) : (uint)0; }
//        }

//        public UInt32 Index32Count
//        {
//            get { return (this.Flags & 0x40) != 0 ? this.StepCount : (uint)0; }
//        }

//        [RanbuDataProperty(SizeParam = "Timing8Count")]
//        public Byte[] StepTimings8 { get; set; }

//        [RanbuDataProperty(SizeParam = "Timing16Count")]
//        public UInt16[] StepTimings16 { get; set; }

//        [RanbuDataProperty(SizeParam = "Index16Count", OffsetParam = "StepIndexOffset")]
//        public UInt16[] StepIndices16 { get; set; }

//        [RanbuDataProperty(SizeParam = "Index32Count")]
//        public UInt32[] StepIndices32 { get; set; }
//    }

//    [RanbuDataType(Monoblock = false)]
//    public class EmaSkelHeader : RanbuDataItem
//    {
//        [RanbuDataProperty]
//        public UInt16 NodeCount { get; set; }

//        [RanbuDataProperty]
//        public UInt16 Unk0x02 { get; set; } // matrix count?

//        [RanbuDataProperty]
//        public UInt16 IKDataCount { get; set; }

//        [RanbuDataProperty]
//        public UInt16 Unk0x06 { get; set; } // something count?

//        [RanbuDataProperty]
//        public UInt32 SkelStartOffset { get; set; }

//        [RanbuDataProperty]
//        public UInt32 SkelNameAddressOffset { get; set; }

//        [RanbuDataProperty]
//        public UInt32 Unk0x10 { get; set; }

//        [RanbuDataProperty]
//        public UInt32 Unk0x14 { get; set; }

//        [RanbuDataProperty]
//        public UInt32 Unk0x18 { get; set; }

//        [RanbuDataProperty]
//        public UInt32 MatrixOffset { get; set; }

//        [RanbuDataProperty]
//        public UInt32 IKDataOffset { get; set; }

//        [RanbuDataProperty(OffsetParam = "SkelStartOffset", SizeParam = "NodeCount", OffsetMode = OffsetMode.GotoAndStay)]
//        public EmaSkelNode[] Nodes { get; set; }

//        [RanbuDataProperty(OffsetParam = "SkelNameAddressOffset", SizeParam = "NodeCount", OffsetMode = OffsetMode.GotoAndStay)]
//        public UInt32[] SkelNameFarm { get; set; }

//        [RanbuDataProperty(OffsetArrayParam = "SkelNameFarm", OffsetMode = OffsetMode.GotoAndStay)]
//        public string[] SkelNames { get; set; }

//        [RanbuDataProperty(OffsetParam = "IKDataOffset", SizeParam = "IKDataCount", OffsetMode = OffsetMode.GotoAndStay)]
//        public EmaSkelIKData[] IKDatas { get; set; }

//        [RanbuDataProperty(OffsetParam = "MatrixOffset", OffsetMode = OffsetMode.GotoAndStay)]
//        public Matrix44 Matrix { get; set; }

//        // TODO matrix
//    }

//    [RanbuDataType(Monoblock = true)]
//    public class EmaSkelNode : RanbuDataItem
//    {
//        [RanbuDataProperty]
//        public UInt16 Parent { get; set; }

//        [RanbuDataProperty]
//        public UInt16 Child1 { get; set; }

//        [RanbuDataProperty]
//        public UInt16 Sibling { get; set; }

//        [RanbuDataProperty]
//        public UInt16 Child3 { get; set; }

//        [RanbuDataProperty]
//        public UInt16 Child4 { get; set; }

//        [RanbuDataProperty]
//        public UInt16 Flags { get; set; }

//        [RanbuDataProperty]
//        public Single UnknownScale { get; set; }

//        [RanbuDataProperty]
//        public Matrix44 Matrix{ get; set; }

//        public UInt16 Number { get; set; }

//        public Vector3 Translation;

//        public Vector3 Scale;

//        public Vector3 Rotation;

//        public Vector4 RotationQuaternion;

//        public Matrix44 AnimatedMatrix;

//        public Vector3 AnimatedTranslation;

//        public Vector3 AnimatedScale;

//        public Vector3 AnimatedRotation;

//        public Vector4 AnimatedQuaternion;

//            // TODO: decompose matrix
//    }

//    [RanbuDataType(Monoblock = true)]
//    public class EmaSkelIKData : RanbuDataItem
//    {
//        [RanbuDataProperty]
//        public UInt16 Method { get; set; }

//        [RanbuDataProperty]
//        public UInt16 TotalSize { get; set; }

//        [RanbuDataProperty(SizeParam = "DataSize")]
//        public Byte[] Data { get; set; }

//        public UInt32 DataSize
//        {
//            get
//            {
//                if (this.TotalSize > 0x24) throw new VerificationException();
//                return (uint)(this.TotalSize - 4);
//            }
//        }
//    }

//    [RanbuDataType(Monoblock = true)]
//    public class EmaSkelUnkData : RanbuDataItem
//    {
//        [RanbuDataProperty]
//        public UInt16 RotationFlags { get; set; }

//        [RanbuDataProperty]
//        public UInt16 TranslationFlags { get; set; }

//                [RanbuDataProperty]
//        public UInt16 Index { get; set; }

//                [RanbuDataProperty]
//        public UInt16 Unk0x06 { get; set; }
//    }
//}
